<?php
function redirect($url=''){
	echo '<script language="javascript">window.location = "'.$url.'" </script>';
	exit();
}

function transfer($msg,$page="index.php")
{
	 $showtext = $msg;
	 $page_transfer = $page;
	 include("./view/transfer_tpl.php");
	 exit();
}

#Ping 
function ping($ip='')
{
	$str = exec("ping -n 1 -w 1 ".$ip, $input, $result);
	
	if ($result == 0)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function format_date_data($date='')
{
	$array = explode('/',$date);
	return $array[2]."-".$array[0]."-".$array[1];
}

function format_date_view($date='')
{
	$array = explode('-',$date);
	return $array[2]."/".$array[1]."/".$array[0];
}

/**
 * Converts a dotquad IP string into a hexidecimal IP string
 * @access private
 * @param string $user_ip Dot quad variant of the IP address
 * @return string Hexadecimal encoding of the dot quad IP address
 */
function encode_ip($user_ip) {
    // First thing to do, split the IP into its quads
    $ip = explode('.', $user_ip);
   
    // Now we convert it and return it to the caller
    return sprintf('%02x%02x%02x%02x', $ip[0], $ip[1], $ip[2], $ip[3]);
}

?>
